print("load script dz_minrui.lua.")
local s = {}

function getComboPoints()
    return UnitPower('player', 4)
end

function MaxComboPoints()
    return UnitPowerMax('player', 4)
end

function getEnergy()
    return UnitPower('player', 3)
end

function MaxEnergy()
    return UnitPowerMax('player', 3)
end

function ut._attack() 
	local energy = getEnergy()
	local comboPoints = getComboPoints()

	if getBuffRemianTime('player', '死亡符记') < 5 and 
		ut.cast( '死亡符记', 'target') then
		return 	
	end

	if getDebuffRemainTime('target', '夜刃') < 3 and
		ut.cast('夜刃', 'target') then
		return
	end

	-- if ut.cast('赤喉之咬', 'target') then
	-- 	return
	-- end

	if 4<=comboPoints and 0 < getDebuffRemainTime( 'target', '夜刃' ) 
		and ut.cast('刺骨',  'target') then
		return
	end

	if ut.cast('暗影打击', 'target') then
		return
	end

	if GetShapeshiftForm() == 0 and --[[getCD('暗影之舞') > 1 and]] ut.cast('背刺', 'target') then
		return
	end
end

-- registerEvent('PLAYER_LEAVE_COMBAT', function( ... )
-- 	print('leave combat')
-- 	do
-- 		return
-- 	end
-- 	if GetShapeshiftForm() ~= 0 then
-- 		return
-- 	end
-- 	ut.newThread(function()
-- 		ut.waitSpellCastSuccess('潜行')
-- 		ut.stop()
-- 	end)
-- end)



-- LoadScript("dz_minrui_macro.lua")
return s
